package util;

import java.util.HashMap;
import java.util.Map;

public class MmUtil {

	private static Map<Character, String> mmMap = new HashMap<Character, String>();
	static {
		mmMap.put('b', "0");
		mmMap.put('u', "1");
		mmMap.put('5', "2");
		mmMap.put('f', "3");
		mmMap.put('1', "4");
		mmMap.put('j', "5");
		mmMap.put('n', "6");
		mmMap.put('7', "7");
		mmMap.put('9', "8");
		mmMap.put('p', "9");
	}

	public static String transfer(String source) {
		StringBuffer sb = new StringBuffer();
		for (int i = 0; i < source.length(); i++) {
			char c = source.charAt(i);
			sb.append(mmMap.get(c));
		}
		return sb.toString();
	}

	public static String desnet(String cecInfo) {
		StringBuffer sb = new StringBuffer();
		String[] cardInfo = cecInfo.split("x");
		for (int i = 0; i < cardInfo.length; i++) {
			String tmp = cardInfo[i];
			int val = Integer.parseInt(MmUtil.transfer(tmp));
			sb.append(val / (i + 1));
		}
		return sb.toString();
	}

	public static void main(String[] args) {
		String test = "ux1xpxunxbxnxu1x51xfnxbxuux51xfpxjnxbxunxf1xj1x7nxbx5ux55xu91x51xjbx79x";
		System.out.println(MmUtil.desnet(test));
	}
}
